import type { ApiResponse, BaseRecordSearchWrapper, BaseRecordVo, TableQuery } from '@/types/basetypes';
import type { DepartmentForm, DepartmentTree } from '@/types/employess/department/types';
import type { TableConfigrationType } from '@/types/table-configtypes';
import type { QueryWrapper, UpdateWrapper } from '@/types/wrappertypes';
import request from '@/utils/request'

//查询部门列表信息
export function _getDepartmentList(params: object) {
  return request({
    url: '/staff-department/query-all',
    method: 'GET',
    params: params,
  });
}

//查询部门信息
export const _getDepartmentInfo = async (params: { id: string }): Promise<ApiResponse<DepartmentForm>> => {
  const { id } = params;
  return request({
    url: `/staff-department/query-details/${id}`,
    method: 'GET',
  });
}

//保存部门信息
export const _saveDepartmentInfo = async (params: object): Promise<ApiResponse<void>> => {
  return request({
    url: '/staff-department/insert',
    method: 'POST',
    data: params,
  });
}

//更新部门信息
export const _modifyDepartmentInfo = async (params: UpdateWrapper): Promise<ApiResponse<void>> => {
  return request({
    url: '/staff-department/modify',
    method: 'POST',
    data: params,
  });
}

//删除部门信息
export const _delDepartmentInfoByIds = async (ids: string): Promise<ApiResponse<void>> => {
  return request({
    url: '/staff-department/del-ids',
    method: 'POST',
    data: { ids: ids },
  });
}

//查询部门操作记录
export const _getRecordInfos = async (params: { id: string }): Promise<ApiResponse<BaseRecordVo[]>> => {
  const { id } = params;
  return request({
    url: `/staff-department/query-details-record/${id}`,
    method: 'GET',
  });
}

//新增备注
export const _saveRecordRemarkInfos = async (params: { bizId: string, remark: string }): Promise<ApiResponse<void>> => {
  return request({
    url: '/staff-department/insert-remark',
    method: 'POST',
    data: params,
  });
}

//搜索操作记录
export const _searchRecordRemarkInfos = async (params: BaseRecordSearchWrapper): Promise<ApiResponse<BaseRecordVo[]>> => {
  return request({
    url: '/staff-department/query-details-record-wrapper',
    method: 'POST',
    data: params,
  });
}

//查询部门列表select配置数据
export const _getDepartmentTableConfigeration = async (): Promise<ApiResponse<TableConfigrationType>> => {
  return request({
    url: `/staff-department/query-table-config`,
    method: 'GET',
  });
}



//查询部门列表操作数据
export const _getDepartmentTableList = async (params: QueryWrapper): Promise<ApiResponse<TableQuery<DepartmentForm>>> => {
  return request({
    url: `/staff-department/query-table-list`,
    method: 'POST',
    data: params
  });
}


//查询部门树结构
export const _getDepartmentTree = async () : Promise<ApiResponse<DepartmentTree[]>> =>{
  return request({
    url: `/staff-department/query-tree`,
    method:'GET'
  })
}

